<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<button @click="handleClick()">点击</button>
		<text>水果总量 {{totalNum}}</text>
		<view v-for="item in list" :key="item.name">
			<text>{{item.name}}</text>
			<text>{{item.num}}</text>
		</view>
		<my-component />
	</view>
</template>

<script setup>
	// export default {
	// 	data() {
	// 		return {
	// 			title: 'Hello'
	// 		}
	// 	},
	// 	onLoad() {

	// 	},
	// 	methods: {

	// 	}
	//}
	import { computed, reactive, ref } from 'vue';
	import { onLoad } from '@dcloudio/uni-app'
	const title = ref('Hello')
	onLoad(()=>{
		console.log('onload生命周期')
	})
	const list = reactive([
		{name:'apple',num:1},
		{name:'orange',num:2},
		{name:'bunanan',num:3}
	])
	const handleClick= ()=>{
		list.forEach(item =>{
			item.num++
		})
	}
	const totalNum = computed(()=>{
		return list.reduce((total,item)=>{return total + item.num},0)
	})
	
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
